<?php
class logininstance
{
	public $data;
	public $Fields;
	public $Info;
	public $Login;
	public function __construct($Login)
	{
		$this->Login = $Login;
		$this->setAll($Login);
		$this->Fields = array
					(
						"id" => "Info['login']['id']",
						"username" => "Info['login'][username]",
						"email" => "Info[login][email]",
						"level" => "Info[login][level]",
						"type" => "Info[login][type]",
						);
	}
	
	/*
	*	Sets All The Login Variables to be Easily Accessible
	*/
	public function setAll($array)
	{
		foreach($array['login'] as $key => $value)
		{
			$this->Info[$key] = $value;
		}
	}
	
	/*
	*	Catches all Non-Correct Variable Sets
	*/
	public function __set($name, $value)
	{
		$this->data[$name] = $value;
	}
	
	/*
	*	Catches all Non-Correct Varible Gets
	*/
	public function __get($name)
	{
		if($name == "prefs")
		{
			return $this->returnPrefs();
		}
		if($name == "display")
		{
			return $this->returnDisplayPrefs();
		}
		return $this->getVar($name);
	}
	/*
	*	Returns True on all ISSETS
	*/
	public function __isset($name)
	{
		return true;
	}
	/*
	*	Returns the User Prefrences
	*/
	public function returnPrefs()
	{
		return $this->Login["prefs"];
	}
	
	/*
	*	Returns the User Prefrences
	*/
	public function returnDisplayPrefs()
	{
		return $this->Login["prefs"]["display"];
	}
	
	/*
	*	Catches all Improper Calls
	*/
	public function __call($function, $args="")
	{
		
	}
	/*
	*	When Class is echoed, returns a array of Login Info
	*/
	public function __toString()
	{
		$str = "Login Info: <Br>\n";
		foreach($this->Info as $key => $value)
		{
			$str .= $key . " => " . $value . "<br>\n";
		}
		return $str;
	}
	
	/*
	*	Returns the Proper Variable out of the Login Info Array
	*/
	public function getVar($var)
	{
		if(@$this->Info[$var])
		{
			return $this->Info[$var];
		}
		else
		{
			return false;
		}
	}
}